#include<iostream>
#include<map>
using namespace std;
typedef long long LL;
const int N = 1e6 + 10;
const LL mod = 998244353;
int n, m;
int cnt[N];
map<int, int>mp;
map<pair<int, int>, int>mp1;
LL fun(LL x, LL y)
{
	return (1ll) * (x ^ y) * (x | y) * (x & y);
}
int main()
{
	cin >> n >> m;
	while (m--) {
		int x, y;
		scanf_s("%d%d", &x, &y);
		//if (mp1[{x, y}] || mp1[{y, x}])continue;
		cnt[x]++;
		cnt[y]++;
		//mp1[{x, y}] = mp1[{y, x}] = 1;
	}
	for (int i = 1; i <= n; i++) {
		if (cnt[i]) {
			mp[cnt[i]]++;
		}
	}
	LL ans = 0;
	//cout << fun(1, 3) << endl;
	for (auto item : mp) {
		//cout << item.first << "   " << item.second << endl;
		for (auto it2 : mp) {
			if (item.first != it2.first) {
				LL ans1 = fun(item.first, it2.first);
				ans1 *= (1ll * mp[item.first] * mp[it2.first]);
				ans1 /= 2;
				ans += ans1;
				ans %= mod;
				//ans %= mod;
			}
		}
	}
	ans %= mod;
	cout << ans << endl;
	return 0;
}